package com.ioftv.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ioftv.entity.SysMenu;
import com.ioftv.mapper.SysMenuMapper;
import com.ioftv.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 菜单Service实现类
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {

    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Override
    public List<SysMenu> getAllMenus() {
        LambdaQueryWrapper<SysMenu> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysMenu::getStatus, 1);
        queryWrapper.orderByAsc(SysMenu::getParentId, SysMenu::getOrderNum);
        return this.list(queryWrapper);
    }

    @Override
    public List<SysMenu> getMenusByUserId(Long userId) {
        return sysMenuMapper.selectMenusByUserId(userId);
    }
}